"""
实现感知机的逻辑与和
"""
def AND(x1,x2):
    w1 = w2 = 0.5
    theta = 0.7
    temp = x1*w1 + x2*w2
    if temp <= theta:
        return 0
    else:
        return 1

# print(AND(1,1))
# print(AND(0,1))
# print(AND(1,0))
# print(AND(0,0))

def OR(x1,x2):
    w1 = w2 = 0.5
    theta = 0.2
    temp = w1 * x1 + w2 * x2

    if temp <= theta:
        return 0
    else:
        return 1

# print(OR(1,1))
# print(OR(0,1))
# print(OR(1,0))
# print(OR(0,0))


def XOF(x1,x2):
    s1 = not AND(x1,x2)
    s2 = OR(x1,x2)
    y = AND(s1,s2)
    return y

print(XOF(1,1))
print(XOF(0,1))
print(XOF(1,0))
print(XOF(0,0))